<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if(!function_exists('getTopNav')) {
	function getTopNav() {
        echo '<div class="navbar navbar-inverse navbar-fixed-top">';
        echo '<div class="navbar-inner">';
        echo '<div class="container">';
        echo '<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">';
        echo '<span class="icon-bar"></span>';
        echo '<span class="icon-bar"></span>';
        echo '<span class="icon-bar"></span>';
        echo '</a>';
        echo '<a class="brand" href="' . base_url() . 'Home" title="' . config_item('site_popup') . '">' . config_item('site_title') . '</a>';
        echo getTopRightDropDown();
        echo '<div class="nav-collapse">';
        echo '<ul class="nav">';
        echo '<li class="active"><a href="' . base_url() . 'Home" title="' . config_item('site_popup') . '"><i class="icon-home icon-white"></i> Home</a></li>';
        
        $CI = & get_instance();
        if($CI->session->userdata('role') == '0') {
            echo '<li><a href="' . base_url() . 'Admin" title="Administration"><i class="icon-wrench icon-white"></i> Admin</a></li>';
        }

		echo '<li><form class="form-search pull-left" action="Search" method="POST">
					  <input type="text" class="input search-query">
					  <button type="submit" class="btn">Search</button>
					</form></li>';
        echo '</ul>';
        echo '</div><!--/.nav-collapse -->';
        echo '</div>';
        echo '</div>';
        echo '</div>';
    
	}
}

if(!function_exists('getTopRightDropDown')) {
	function getTopRightDropDown() {
        $CI = & get_instance();
        echo '<div class="btn-group pull-right">';
        echo '<a class="btn dropdown-toggle" data-toggle="dropdown" href="#" title="Logged in as ' . $CI->session->userdata('username') . '">';
        echo '<i class="icon-user"></i> ' . $CI->session->userdata('username');
        echo ' <span class="caret"></span>';
        echo '</a>';
        echo '<ul class="dropdown-menu">';
        echo '<li><a href="profile.php">Profile</a></li>';
        echo '<li class="divider"></li>';
        echo '<li><a href="Login/logout">Logout</a></li>';
        echo '</ul>';
        echo '</div>';
    }
}

if(!function_exists('getCategorySelBox')) {
	function getCategorySelBox($id, $name, $selected) {
		$CI = & get_instance();
		$query = $CI->db->query('SELECT * FROM categories WHERE deleted = \'0\'');
        
		$categories = $query->result();
		
		echo '<select id = "' . $id . '" name = "' . $name . '">';
		foreach ($categories as $row) {
			echo '<option ';
	        if ($selected == $row->category)
	            echo ' selected ';
	        echo ' >'. $row->category . '</option>';
		}
		echo '</select>';        
    }
}	
?>